Getting and Setting the Value of a Slider Control

Description

The value for a Slider Control can be set using javascript.

Setting the Value for a Slider Control

The Slider Control is a Data Control. The value can be set for all Data Controls using the {dialog.object}.setValue method. For single value sliders, setting the value is straightforward. For a two value slider, you must pass in an array that defines the start and end value for the slider. See examples below:

//Set the value for a one value slider:
{dialog.object}.setValue('S1',12);

//Set the value for a two value slider:
{dialog.object}.setValue('S2',[10,20]);

Getting the Value for a Slider Control

As with setting the value, you can use {dialog.object}.getValue to get the value from a Slider Control. getValue will return the value for a single value slider as expected:

var value = {dialog.object}.getValue('S1');
alert("Slider value is: " + value);

For a two value slider, {dialog.object}.getValue will return a string with the format "start..end". If you wanted to set the value in a two value slider with the current value in another two value slider, you would need to convert the string to an array:

var value = {dialog.object}.getValue('S2');
value = value.split("..");

{dialog.object}.setValue('S3',value);

Example Component

Click here to download an example component (shown in the image below) that demonstrates getting and setting the value of one and two value Slider Controls.

images/slidersExample.png
A UX component with three slider controls that demonstrates getting and setting Slider Control values.

See Also